/******************************************************************************
 * SVN­Version­Information:
 * ­­­­­­­­­­­­­­­­­­­­­­­­---------------------
 * $LastChangedRevision: 130 $
 * $LastChangedBy: SD $
 * $LastChangedDate: 2009-06-23 17:42:49 +0200 (Tue, 23 Jun 2009) $
 * $HeadURL: svn://lvis10.fbm.fht-stuttgart.de/common/Common/src/de/hft_stuttgart/botwar/common/models/GameResultInfo.java $
 ******************************************************************************/
package de.hft_stuttgart.botwar.common.models;

import java.io.Serializable;

/**
 * Holds all information about the result of a game.
 * @author pmv-mail@gmx.de, c.a.duevel@gmail.com
 */
public class GameResultInfo implements Serializable {

    private final String playerID;
    private final Result gameResult;
    private final long experience;

    /**
     * Contains the possibilities of a result of a game.
     */
    public enum Result {

        WON, LOST, DRAW
    }

    /**
     * New GameResultInfo
     * @param playerID winner of the game
     * @param gameResult result of the game
     * @param experience of each player
     */
    public GameResultInfo(final String playerID,
            final Result gameResult, final long experience) {
        this.playerID = playerID;
        this.gameResult = gameResult;
        this.experience = experience;
    }

    /**
     * Returns the experience.
     * @return experience of a player
     */
    public long getExperience() {
        return experience;
    }

    /**
     * Returns the game result.
     * @return gameResult of a game.
     */
    public Result getResult() {
        return gameResult;
    }

    /**
     * Returns the player id
     * @return playerID winner
     */
    public String getPlayerId() {
        return playerID;
    }

    /**
     * Overrides method equals.
     * @param obj to compare
     * @return boolean true or false
     */
    @Override
    public boolean equals(final Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final GameResultInfo other = (GameResultInfo) obj;
        if ((this.playerID == null) ? (other.playerID !=
                null) : !this.playerID.equals(other.playerID)) {

            return false;
        }
        if (this.gameResult != other.gameResult) {
            return false;
        }
        if (this.experience != other.experience) {
            return false;
        }
        return true;
    }

    /**
     * Overrides method hashCode.
     * @return hash code
     */
    @Override
    public int hashCode() {
        return super.hashCode();
    }

    /**
     * Overrides method to String.
     * @return String string
     */
    @Override
    public String toString() {
        return super.toString();
    }
}
